<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>菜单列表</title>
  <link rel="stylesheet" href="./css/style.css" />
</head>

<body>
  <h3 class="big-tit">菜谱列表</h3>
  <ul class="list-box">
    <!-- <li>
      <a href="info.html">
        <img src="http://yun.itheima.com/Upload/Images/20220627/62b924298e658.jpg" alt="" />
        <h3>菜单名称</h3>
      </a>
    </li>
    <li>
      <a href="info.html">
        <img src="http://yun.itheima.com/Upload/Images/20220627/62b924298e658.jpg" alt="" />
        <h3>菜单名称</h3>
      </a>
    </li>
    <li>
      <a href="info.html">
        <img src="http://yun.itheima.com/Upload/Images/20220627/62b924298e658.jpg" alt="" />
        <h3>菜单名称</h3>
      </a>
    </li>
    <li>
      <a href="info.html">
        <img src="http://yun.itheima.com/Upload/Images/20220627/62b924298e658.jpg" alt="" />
        <h3>菜单名称</h3>
      </a>
    </li>
    <li>
      <a href="info.html">
        <img src="http://yun.itheima.com/Upload/Images/20220627/62b924298e658.jpg" alt="" />
        <h3>菜单名称</h3>
      </a>
    </li>
    <li>
      <a href="info.html">
        <img src="http://yun.itheima.com/Upload/Images/20220627/62b924298e658.jpg" alt="" />
        <h3>菜单名称</h3>
      </a>
    </li>
    <li>
      <a href="info.html">
        <img src="http://yun.itheima.com/Upload/Images/20220627/62b924298e658.jpg" alt="" />
        <h3>菜单名称</h3>
      </a>
    </li>
    <li>
      <a href="info.html">
        <img src="http://yun.itheima.com/Upload/Images/20220627/62b924298e658.jpg" alt="" />
        <h3>菜单名称</h3>
      </a>
    </li> -->
  </ul>
  <p class="more">数据正在加载中...</p>
  <p class="noinfo">没有数据了...</p>
</body>

<script src="./JS/jquery.js"></script>
<script src="./JS/axios.js"></script>
<script>
  $.ajax({
    method: 'GET',
    url: 'http://124.223.14.236:3001/api/recipe',
    data: {
      pageSize:50
    },
    success(res) {
      console.log(res)
      render(res.data.list)
    }
  })

  function render(data) {
    const newList = data.map(item => {
      const { id, img, name, description } = item
      return `
      <li>
      <a href="info.html" data-id=${item.id}>
        <img src=http://124.223.14.236:3001/public/${item.img} />
        <h3>${name}</h3>
      </a>
      </li> -->      
      `
    }).join('')
    $('.list-box').html(newList)
  }

  $('.list-box').on('click','a',function(){
    localStorage.setItem('idajax06',$(this).attr('data-id'))
  })

</script>


</html>